import java.util.Scanner;

public class One {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int a;
        int b;
        for (;;) {
            System.out.println("高");
            a = sc.nextInt();
            System.out.println("宽");
            b = sc.nextInt();
            if (a >= 3 && b > 3) {
                break;
            } else {
                System.out.println("再次输入高和宽");
            }
        }
            for (int c=1;c<=a;c++){
                System.out.print("*");
                for (int d=1;d<=b-2;d++){
                   if (c==1||c==a){
                       System.out.print("*");
                   }else {
                       System.out.print(" ");
                   }
                }
                System.out.print("*");
                System.out.println();
            }
        }
    }

